import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/assets/init.css'

// 树形控件
import ZkTable from 'vue-table-with-tree-grid'

Vue.component('tree-table', ZkTable)
    // 
import VueQuillEditor from 'vue-quill-editor'

// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor);

// 
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

import axios from 'axios'

axios.defaults.baseURL = "https://lianghj.top:8888/api/private/v1/"
axios.defaults.timeout = 3000

axios.interceptors.request.use(function(config) {
    // 在发送请求之前做些什么
    let token = window.sessionStorage.getItem("token")

    config.headers.Authorization = token
    return config;
}, function(error) {
    // 对请求错误做些什么
    return Promise.reject(error);
});

Vue.prototype.$http = axios

// 过滤器
Vue.filter('dateFormat', function(val) {


    const sj = new Date(val)
    const y = sj.getFullYear()
    const m = (sj.getMonth() + 1 + '').padStart(2, '0')
    const d = (sj.getDate() + '').padStart(2, '0')
    const hh = (sj.getHours() + '').padStart(2, '0')
    const mm = (sj.getMinutes() + '').padStart(2, '0')
    const ss = (sj.getSeconds() + '').padStart(2, '0')
    return `${y}-${m}-${d}.${hh}:${mm}:${ss}`
})


Vue.config.productionTip = false

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')